<%@ page contentType="text/html;charset=UTF-8" isELIgnored="false" autoFlush="true"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<span class="title1">已发送消息</span>
<table class="its" border="0" width="100%" style="word-wrap:break-word;table-layout:fixed;">
<html:form action="/msg" onsubmit="return msgValidate(this);">
<html:hidden property="id"/>
<input type="hidden" name="action" value="delete"/>
    <tr>
        <td width="20%" align="right">标题&nbsp;</td>
        <td><c:out value="${message.title}"/></td>
    </tr>
    <tr>
        <td align="right">接收者&nbsp;</td>
        <td>
        <c:if test="${empty message.mrIaskUserByToUserId}">
            <c:out value="${message.toUserLoginName}"/>
        </c:if>
        <c:if test="${not empty message.mrIaskUserByToUserId}">
            <c:out value="${message.mrIaskUserByToUserId.loginName}"/>
        </c:if>
        </td>
    </tr>
    <tr>
        <td align="right">发送日期&nbsp;</td>
        <td><fmt:formatDate value="${message.postDate}" type="both" pattern="yyyy-MM-dd HH:mm:ss"/></td>
    </tr>
    <tr>
        <td valign="top"  align="right">内容&nbsp;</td>
        <td><pre><c:out escapeXml="false" value="${message.content}"/></pre></td>
    </tr>
    <tr>
        <td align="right">&nbsp;</td>
        <td>
        <html:link action="/msg.mrqa?action=gotlist">
        <input type="button" name="sendMsgBtn" value="返回" onclick="goback();"/>
        </html:link>
        &nbsp;&nbsp;&nbsp;&nbsp;
        <input type="submit" name="delMsgBtn" value="删除"/>
        <c:if test="${not empty message.mrIaskUserByToUserId}">
        &nbsp;&nbsp;&nbsp;&nbsp;
        <input type="button" name="sendMsgBtn" value="发新消息" onclick="sendMsg(this)"/>
        </c:if>
        </td>
    </tr>
</html:form>
</table>
<script type="text/javascript">
    function goback()
    {
        window.location.href = "<c:url value="/msg.mrqa?action=gotlist"/>";
    }
</script>
    <c:if test="${not empty message.mrIaskUserByToUserId}">
    <div id="sendMsgDiv" style="display:none;border:1 solid #ccc;">
    <html:form action="/msg" onsubmit="return msgValidate(this);">
        <input type="hidden" name="action" value="add"/>
        <input type="hidden" name="from" value="views"/>
        <input type="hidden" name="toUserId" value="<c:out value="${message.mrIaskUserByToUserId.id}"/>"/>
        <p>给<b><c:out value="${message.mrIaskUserByToUserId.loginName}"/></b>发新消息</p>
        <p>
            主题：<input type="text" name="title" value="<c:out value="${message.title}"/>" size="30" maxlength="30"/>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input type="submit" value="发送"/>
        </p>
        <p>
            内容：<textarea name="content" rows="3" cols="50"></textarea>(最长200个字符)
        </p>
    </html:form>
    <script type="text/javascript">
        function sendMsg(pButton)
        {
            var sendMsgDiv = document.getElementById("sendMsgDiv");
            if(sendMsgDiv.style.display == "none")
            {
                sendMsgDiv.style.display = "block";
            }
            else
            {
                sendMsgDiv.style.display = "none";
            }
        }
        function msgValidate(pForm)
        {
            var title = pForm.title.value;
            if(title == "")
            {
                alert("主题必须大于6个字符！");
                pForm.title.focus();
                return false;
            }
            var content = pForm.content.value;
            if(content.length > 200)
            {
                alert("内容必须小于200个字符！");
                return false;
            }
            return true;
        }
    </script>
    </div>
    </c:if>
